<template>
<!-- 活动列表 -->
  <div style="height:520px">
    <FilterTable
      ref="table"
      height='450'
      :columns="columns"
      :dataSource='dataSource'
      :isSelectColumn=false
      :fetchapi="fetchParams"
      :params="flterValue"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
    >
      <template slot="controls" v-if="value.type!=='show'">
        <el-button size="small" type="primary" icon="el-icon-plus" @click="openDialog(null,'add')" >新增</el-button>
      </template>
    </FilterTable>
    <!-- 经销商弹窗 -->
    <BaseDialog
      title="添加活动"
      :visible.sync="visibleDialog"
      width="800px"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <addMadal  v-model="initModal"  @close="closeDialog" />
    </BaseDialog>
  </div>
</template>

<script>
import addMadal from './infoActivityDialog'
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
   components: {
    addMadal
  },
  props:{
    value: {
      type: Object,
      required: true
    },
  },
  data() {
    return {
      visibleDialog: false,
      initModal:{},
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchParams: null  , //ipa 接口
      dataSource:[
        {field3:'2',field4:'天乐'},
        {field3:'3',field4:'倒萨范德萨'},
        {field3:'4',field4:'大撒反对'},
        {field3:'5',field4:'单独发放'},
        {field3:'6',field4:'猪吗哩'}
      ]
    };
  },
  mounted() {
    console.log(this.value) //获取到行id 
    //请求接口进行赋值，自己写吧
  },
  methods: {
     //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.editHandle(props.row,'eidt')}>
                  删除
                </el-button>
              </div>
            );
          }
        },
        { title: '活动车型', dataIndex: 'field3', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }},
        { title: '活动地点', dataIndex: 'field4', sorter: true },
        { title: '活动周期', dataIndex: 'field6', sorter: true },
        { title: '是否必做', dataIndex: 'field7', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }},
        { title: '活动时间', dataIndex: 'field8', dateFormat:'yyyy-MM-dd',  sorter: true  },
        { title: '活动名称', dataIndex: 'field80',  sorter: true  },
        { title: '活动主题', dataIndex: 'field9',  sorter: true },
        { title: '活动目的', dataIndex: 'field10',  sorter: true },
        { title: '活动形式', dataIndex: 'field11',  sorter: true }
      ];
    },
    openDialog(row, type) {
      this.initModal={
        type:type,
        id:1001
      }
      this.visibleDialog = true;
    },
    closeDialog(data) {
      //返回数据逻辑自己写
      this.visibleDialog = data.visible; //关闭弹窗
    }
  }
}
</script>